package com.pts.servlet.enterprise;


import com.pts.dao.EnterpriseDao;
import com.pts.vo.Enterprise;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

//处理welcome页面请求，转发到enterprise/list.jsp或product/list.jsp页面
//功能是通过查找所有公司信息

@WebServlet(value = "/entselect")
public class SelectServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        String username = request.getParameter("username");
        request.setAttribute("username",username);
        List<Enterprise > list = new EnterpriseDao().findAll();
        request.setAttribute("ep",list );
        String method = request.getParameter("method");
        if("1".equals(method)){
            request.getRequestDispatcher("admin/enterprise/list.jsp").forward(request,response);
        }
        else{
            request.getRequestDispatcher("admin/product/list.jsp").forward(request,response);
        }
    }
}
